home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
user
/
updatescores.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
7KB
|
286 lines
/* Mode=Run */
/* ***********************************************************************
EXTRACT PROGRAM FOR FOOTBALL REXX SUITE
----------------------------------------
Copyright Mark Naughton 1996
Version Date History
--------------------------------------------------------------------------
1.0 260996 Created. Extracts results from schedule.learn and then
recreates schedule.df
1.1 270996 Tidied, with info messages. Changed to use new filenames.
'Teams.sflearn' is read in, the data is extracted, saved
and then sorted, reread and then updated in a much faster
way. Previous took 35 secs whereas this took 5 secs! Also
would not work because of problems in the loop as all
data has to be in order and the counter was only changed
when it put one in - SHOULD BE when there's a match
regardless of whether its been played or not.
1.2 121196 Updated to accept arguments so it can become a component
of FOOTBALL. Removed all messages.
131196 Added checks for files - if not found, exits without
a message.
201196 Added Iterate as teams can now play each other more
than twice so that other matches (to be played) aren't
written over.
250899 Added error msg to file checks. Added title.
110999 Fixed bug where matches were overwritten because when
teams play each other more than twice, there are more
than one home schedule for each team - the code skipped
over the played matches and overwrote the second schedule.
110999 Converted to use locale. Some error messages, before
reading the locale, will still be in English.
**************************************************************************
Procedure
---------
1. Check files exist. Open Learn file and output file.
2. Read all data from Learn (without '*') and write to output file.
3. Close files.
4. Call external program to sort the output file.
5. Open output file and read into an array. Close file.
6. Delete output file.
7. Open Schedule file and read into an array. Close file.
8. Update Schedule array with data from Learn but only if a match hasn't
been played.
9. Write to Schedule file. Close file. Exit.
************************************************************************** */
PARSE ARG league_file
version = 1
input_file = '.sflearn'
input2_file = '.sf'
input3_file = '.df'
output_file = 'Data/Teams.temp'
autosched = "*AUTOSCHD="
separator = '*'
sdlines. = '???'
selines. = '???'
sdcount = 0
secount = 0
autos = 0
not_played = '__ __'
league_file = "Data/" || league_file
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
locdir = locdir"User/UpdateScores.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
if exists(league_file || input_file) = 0 then do
say
say us_error
say
say us_t1"'"league_file || input_file"'."
exit
end
if exists(league_file || input2_file) = 0 then do
say
say us_error
say
say us_t1"'"league_file || input2_file"'."
exit
end
if exists(league_file || input3_file) = 0 then do
say
say us_error
say
say us_t1"'"league_file || input3_file"'."
exit
end
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(autosched,line) > 0 then
autos = 1
end
close(datafile)
end
else do
say
say us_error
say
say us_t2"'"league_file || input3_file"'"us_t3
exit
end
if autos = 1 then do
say
say us_error
say
say us_t4", "league_file||input3_file", "us_t5
say us_t6
say us_t7" 'UpdateScheduleScores'."
say
exit
end
if open(datafile,league_file || input_file,'r') then do
if open(datafile2,output_file,'w') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
/* if pos(separator,line) = 0 & words(line) > 0 then */
if pos(separator,line) = 0 & line ~= "" then
writeln(datafile2,line)
end
close(datafile2)
end
else do
say
say us_error
say
say us_t8" '"output_file"' "us_t9
exit
end
close(datafile)
end
else do
say
say us_error
say
say us_t2"'"league_file || input_file"'"us_t3
exit
end
address command 'Exec/footsort T'
if open(datafile,output_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
if line ~= "" then do
secount = secount + 1
selines.secount = line
end
end
close(datafile)
end
else do
say
say us_error
say
say us_t2"'"output_file"'"us_t3
exit
end
address command 'delete >NIL: 'output_file
sdcount = 1
if open(datafile3,league_file || input2_file,'r') then do
do while ~eof(datafile3)
line = readln(datafile3)
line = strip(line)
if line ~= "" then do
sdlines.sdcount = line
sdcount = sdcount + 1
end
end
close(datafile3)
end
else do
say
say us_error
say
say us_t2"'"league_file || input2_file"'"us_t3
exit
end
i = 0
done = 0
k = 0
say
say center(us_t10,78)
say "-------------------------------------------------------------------------------"
say
say
say us_t12" :"
say
do j=1 to sdcount
shome = strip(substr(sdlines.j,1,30))
saway = strip(substr(sdlines.j,41,30))
do i=1 to secount
home = strip(substr(selines.i,1,30))
away = strip(substr(selines.i,41,30))
if strip(sdlines.j) == strip(selines.i) then do
k = k + 1
leave
end
else do
if shome = home & saway = away & pos(not_played,sdlines.j) > 0 then do
sdlines.j = selines.i
say " >>"selines.i"<<"
k = k + 1
leave
end
end
end
if k = secount then leave
end
say
say
say "-------------------------------------------------------------------------------"
if open(datafile3,league_file || input2_file,'w') then do
do j=1 to sdcount-1
if j < sdcount-1 then
writeln(datafile3,sdlines.j)
else
writech(datafile3,sdlines.j)
end
close(datafile3)
end
else do
say
say us_error
say
say us_t2"'"league_file || input2_file"'"us_t11
exit
end
exit